package com.copsoftware.utils.exceptions;

public class ObjectConverterException extends RuntimeException {
    private Object source;
    private Class targetType;
    private String addInfo;

    public ObjectConverterException(Object source, Class targetType, String addInfo) {
        this.source = source;
        this.targetType = targetType;
        this.addInfo = addInfo;
    }

    public String toString() {
        StringBuffer buf = new StringBuffer(100);
        buf.append("Object ").append(source).append(" cannot be converted ");
        buf.append(source == null ? null : source.getClass()).append("-->").append(targetType);
        buf.append(addInfo == null ? "" : "(" + addInfo + ")");
        return buf.toString();
    }
}
